package org.xs.web.http.i18n;

import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;

public class LocationRule {
	private static ConcurrentHashMap<String, Properties> cache = new ConcurrentHashMap<String, Properties>();
	
	public static MessageMap message(Locale locale,String name){
		String underline = locale.getLanguage();
		String name_ = name+"_"+underline+".properties";
		Properties pros = cache.get(name);
		if(pros == null){
			pros = new Properties(name_);
			cache.put(name_, pros);
		} 
		return pros.load();
	}
	
	public static Properties properties(Locale locale,String name){
		String underline = locale.getLanguage();
		String name_ = name+"_"+underline+".properties";
		Properties pros = cache.get(name_);
		if(pros == null){
			pros = new Properties(name_);
			cache.put(name_, pros);
		} 
		return pros;
	}
}
